@extends('admin._layouts.default')

@section('main')


      <?php if ($user->hasAccess('admin')){ ?>
      <div class="row-fluid ">
        <div class="span12 box gradient ">
      <div class="title">
            <div class="row-fluid">
                <h3>
                  <i class="fa fa-map-marker"></i> 运营商管理 |
                  <a class="btn btn-info btn-mini mg5" href="{{ route('admin.cities.create') }}"><i class="fa fa-plus-circle"></i> 开通城市</a> |
                  <a class="btn btn-info btn-mini mg5" href="{{ route('admin.cities.export') }}"><i class="fa fa-plus-circle"></i> 导出粉丝数量</a>
                </h3>
            </div>
        </div><!-- End .title -->
        <div class="content top">
          <table id="datatable_city" class="responsive table table-striped table-bordered" style="width:100%;margin-bottom:0; ">
            <thead>
              <tr>
                <th class="jv no_sort"><label class="checkbox "><input type="checkbox"></label></th>
                {{--<th class="no_sort" width="80">管理者</th>--}}
                 <th class="to_hide_phone  no_sort">联系信息 </th>
                 <th class="to_hide_phone  no_sort">所在城市 </th>
                 <th class="to_hide_phone">装机数</th>
                 <th class="to_hide_phone">好评率</th>
                <th class="ue no_sort" width="140">本月装机/季动态</th>
                <th class="ms no_sort" width="140">操作</th>
              </tr>
            </thead>
            <tbody>
            <?php }elseif($user->hasAccess('city')){ ?>
            <div class="row-fluid ">
            <div class="span12 box gradient ">
          <div class="title">
                <div class="row-fluid">
                    <h3>
                      <i class="fa fa-flag"></i> 直营商管理 | <a class="btn btn-info btn-mini mg5" href="{{ route('admin.cities.create') }}"><i class="fa fa-plus-circle"></i> 开通直营商</a>
                    </h3>
                </div>
            </div><!-- End .title -->
            <div class="content top">
              <table id="datatable_city" class="responsive table table-striped table-bordered" style="width:100%;margin-bottom:0; ">
                <thead>
                  <tr>
                    <th class="jv no_sort"><label class="checkbox "><input type="checkbox"></label></th>
                    {{--<th class="no_sort" width="80">管理者</th>--}}
                     <th class="to_hide_phone  no_sort">联系信息 </th>
                     <th class="to_hide_phone  no_sort">片区名称 </th>
                     <th class="to_hide_phone">装机数</th>
                     <th class="to_hide_phone">好评率</th>
                    <th class="ue no_sort" width="120">小区数</th>
                    <th class="ue no_sort" width="100">关注数</th>
                    <th class="ms no_sort" width="140">操作</th>
                  </tr>
                </thead>
                <tbody>
            <?php } ?>
            @foreach($myusers as $myuser)
              <tr>
                @if($user->hasAccess('city'))
                <td><label class="radio "><input @if($myuser->default == 1) checked @endif type="radio" onclick="set_default({{ $myuser->id }})" name="default" value="{{ $myuser->id }}"></label></td>
                @else
                                <td><label class="checkbox "><input type="checkbox"></label></td>

                @endif
                {{--<td><img class="thumbnail small" src="img/message_avatar4.png"></td>--}}
                <td class="to_hide_phone">
                    <i class="fa fa-user"></i> <strong>{{ $myuser->username }}</strong><br/>
                    <i class="fa fa-phone"></i> <strong>{{ $myuser->mobile }}</strong><br/>
                </td>
                <td class="to_hide_phone">
                    @if($user->hasAccess('admin'))
                    <i class="fa fa-map-marker"></i> <strong>{{ $myuser->provincename->name }} {{ $myuser->cityname->name }}</strong><br/>
                    @elseif($user->hasAccess('city'))
                    <i class="fa fa-map-marker"></i> <strong>{{ $myuser->areaname->name }}</strong><br/>
                    @endif
                </td>
                <td>
                    <i class="fa fa-thumbs-up"></i> <strong>{{ $myuser->mount_count }}</strong><br/>
                </td>
                <td >
                <s>5</s><span class="color_orange"  rel="tooltip" data-placement="top" data-original-title=" 5 "><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i></span>
              </td>
                <td class="to_hide_phone">
                    {{ $myuser->area_count }}
                {{--46 <span class="line">5,4,1</span>--}}
                </td>
                @if($user->hasAccess('city'))
                <td class="to_hide_phone">
                {{ $myuser->subscribe }}
                {{--46 <span class="line">5,4,1</span>--}}
                </td>
                @endif

                <td class="ms"><div class="btn-group1">
                    @if($user->hasAccess('city'))
                    <a class="btn btn-small"  onclick="ajax_load('{{ $myuser->id }}','{{ $myuser->username }}')"   rel="tooltip" data-placement="left" data-original-title=" 直营商二维码 " data-toggle="modal" href="#qrcode_city"><i class="gicon-qrcode"></i></a>
                    <a class="btn btn-small" href="{{ route('admin.cities.xiaoqu',array('id'=>$myuser->area)) }}"  rel="tooltip" data-placement="left" data-original-title=" 修改小区 "><i class="gicon-edit"></i></a>
                    @endif
                    {{--<a class="btn btn-inverse btn-small" onclick="set_delete('{{ $myuser->id }}');" rel="tooltip" data-placement="bottom" data-original-title=" 删除 "  data-toggle="modal" href="#confirm_alert"><i class="gicon-trash icon-white"></i></a>--}}
                    <a class="btn btn-inverse btn-small" rel="tooltip"  data-original-title=" 修改密码 " href="{{ route('admin.cities.edit',array('id'=>$myuser->id)) }}"><i class="gicon-edit icon-white"></i></a>
                  </div>
                </td>
              </tr>
              @endforeach

            </tbody>
          </table>
           <div class="row-fluid control-group">
                    <div class="controls inline input-large pull-left">
                      <select data-placeholder="批量处理: " class="chzn-select  " id="default-select" >
                        <option value=""></option>
                        <option value="Kif Kroker">删除</option>

                      </select>
                    </div>
                   <button type="button" class="btn inline">执行</button>
            </div> <!-- End row-fluid -->
        </div><!-- End .content -->
        </div>
        <!-- End box -->
      </div>


@stop


@section('modals')
<div id="qrcode_city" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">直营商二维码</h3>
      </div>
      <div class="modal-body">
        <div class="row-fluid">
          <div class="span6" id="er_img"><img src="{{ URL::asset('ad/img/ajax-loader.gif') }}" /></div>
          <div class="span5"><p>您现在看到的是<i id="er_name"></i>的绑定二维码</p></div>
        </div>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>

<div id="confirm_alert" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
  <form action="{{ route('admin.cities.deleteit') }}" id="form_delete" method="post">
    <div class="modal-content">
      <div class="modal-header">
      <input type="hidden" name="delete_id" id="delete_id" value="">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">确定本次操作吗？</h3>
      </div>
      <div class="modal-body">
        <i class=" icon-warning-sign color_red pull-left fs_24"></i>

        <p>一旦【确定】，本次操作不可撤销。</p>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" onclick="delete_it();" class="btn btn-primary">确定</button>
      </div>
    </div>
    </form>
  </div>
</div>
@stop


@section('script')
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/full-calendar/fullcalendar.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.peity.min.js') }}"></script>
<script type="text/javascript" language="javascript" src="{{ URL::asset('ad/js/plugins/datatables/js/jquery.dataTables.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/chosen/chosen/chosen.jquery.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/flot/jquery.flot.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.uniform.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/raphael.2.1.0.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/justgage.1.0.1.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/scripts.js') }}"></script>


    <script type="text/javascript" charset="utf-8">
    // Datatables
    $(document).ready(function() {
      var dontSort = [];
                $('#datatable_city thead th').each( function () {
                    if ( $(this).hasClass( 'no_sort' )) {
                        dontSort.push( { "bSortable": false } );
                    } else {
                        dontSort.push( null );
                    }
      } );
      $('#datatable_city').dataTable( {
        "sDom": "<'row table_top_bar'<'row-fluid'>'<'to_hide_phone'>'f'<'>r>t<'row'>",
         "sDom": "<'row table_top_bar'<'row-fluid'<'to_hide_phone' f>>><'row'>",
         "aaSorting": [[ 1, "asc" ]],
        "bPaginate": false,
        "bJQueryUI": false,
        "aoColumns": dontSort

      } );
      $.extend( $.fn.dataTableExt.oStdClasses, {
        "s`": "dataTables_wrapper form-inline"
      } );
    } );
    </script>
    <script>
    function set_delete(id){
        $('#delete_id').val(id);
    }
    function delete_it(){
        $('#form_delete').submit();
    }
    </script>
    <script>

    function ajax_load(id,name){
        var img = '<img src="{{ URL::asset('ad/img/ajax-loader.gif') }}">';
        $('#er_img').html(img);
        $('#er_name').html(name);

        $.post('{{ URL::route('admin.cities.get_code') }}',{id : id},function(data){
            $('#er_img').html(data);
        });
    }

    function set_default(id){
        $.post('{{ URL::route('admin.cities.set_default') }}',{id : id},function(data){});
    }
    </script>
@stop
